﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;

namespace comix.admininstration
{
    public partial class uploadsample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpPostedFile file = Request.Files["Filedata"];
            int id = Convert.ToInt32(Request.Params["BID"]);
            string fn = Request.MapPath("books/s" + id.ToString() + ".cmk");
            file.SaveAs(fn);
            SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["mainconectionstring"].ConnectionString);
            SqlCommand com = new SqlCommand();
            com.Connection = con;
            com.CommandText = "UPDATE BOOKS SET bok_hasdemo = 1, bok_updatedate=getDate() WHERE bok_id = @bokid";
            com.Parameters.Add(new SqlParameter("@bokid", id));
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
        }
    }
}
